package com.woniuxy.woniubook.controller;

import com.woniuxy.woniubook.entity.Book;
import com.woniuxy.woniubook.entity.Booktype;
import com.woniuxy.woniubook.service.BookService;
import com.woniuxy.woniubook.service.BooktypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController // @Controller + ResponseBody

@RequestMapping("/home")
public class HomeController {
    @Autowired
    BooktypeService booktypeService ;

    @Autowired
    BookService bookService ;

    @RequestMapping("/typeList")
    public List<Booktype> booktypeList(){
        List<Booktype> list = booktypeService.list();
        return list ;
    }

    @RequestMapping("/topTen")
    public List<Book> topTen(){
        List<Book> list = bookService.getBookByTopTen();
        return  list;
    }
}
